<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<base href="<?= base_url(1); ?>" />
<link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
<script src="js/time.js?"></script>
<script type="text/javascript">         	

            function addp()
            {
            	var i = document.getElementsByName("childP").length;
                //alert(i);
                //i++; //移除之后，数据加1
                
                str = '<table id ="p'+i+'" width="100%" name="childP">'+    
	                	'<tr><td>&nbsp;</td><td>&nbsp;</td></tr>'+            
		              '<tr>'+
		                '<td><div align="center">'+
		                    '<?= translate("ACTIVITY_ARENASTORE_SHELFID") ?>'+
		                  '</div></td>'+
		                '<td >'+
		                  '<input type="text" name="row[shelfid][]" size="10" id="shelfid'+i+'" >'+
		                '</td>'+
		               '</tr>'+
		               '<tr>'+
		                '<td><div align="center">'+
		                    '<?= translate("ACTIVITY_ARENASTORE_RANK") ?>'+
		                  '</div></td>'+
		                '<td >'+
		                  '<input type="text" name="row[rank][]" size="10" id="rank'+i+'" >'+
		                '</td>'+
		               '</tr>'+
		               '<tr>'+
		                '<td><div align="center">'+
		                    '<?= translate("ACTIVITY_ARENASTORE_COSTID") ?>'+
		                  '</div></td>'+
		                '<td >'+
		                  '<input type="text" name="row[cost_id][]" id="cost_id'+i+'" >'+
		                '</td>'+
		               '</tr>'+
		               '<tr>'+
		                '<td><div align="center">'+
		                    '<?= translate("ACTIVITY_ARENASTORE_PRICE") ?>'+
		                  '</div></td>'+
		                '<td >'+
		                  '<input type="text" name="row[price][]" size="10" id="price'+i+'" >'+
		                '</td>'+
		               '</tr>'+
		               '<tr>'+
		                '<td><div align="center">'+
	                    '<?= translate("ACTIVITY_ARENASTORE_GIFTID") ?>'+
	                  '</div></td>'+
	                  '<td>'+
		                    '<input type="text" size="39" placeholder="<?= translate("PLASE_INPUT_ITEM") ?>" '+ 
	                          	' name="row[giftid][]" id="giftid'+i+'"class="autocomplete" table="type_object" />'+
		              '</td>'+
	              	'</tr>'+
				   '<tr>'+
			              '<td><div align="center">'+
		                    '<?= translate("ACTIVITY_ARENASTORE_MAXCOUNT") ?>'+
		                  '</div></td>'+
		                  '<td >'+
		                  	'<input type="text" name="row[maxcount][]" size="10" id="maxcount'+i+'" >'+
			              '</td>'+
		              	'</tr>'+
		            '<tr>'+
			              '<td><div align="center">'+
		                    '<?= translate("ACTIVITY_ARENASTORE_SUBID") ?>'+
		                  '</div></td>'+
		                  '<td >'+
		                  	'<input type="text" name="row[subid][]" size="10" id="subid'+i+'" >'+
			              '</td>'+
		              	'</tr>'+
		              '</table>';
                //alert(str);	
                $("#add").append(str);
                autocomplete();
                //$("#giftbag_name"+i).formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#shelfid"+i).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                $("#rank"+i).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                $("#price"+i).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                $("#maxcount"+i).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                $("#subid"+i).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                $("#giftid"+i).formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
            }
            function removep()
            {
            	var i = document.getElementsByName("childP").length-1;
                //alert(i);
                if (i > 0)
                {
                    //alert(i);
                    $("#p" + i).remove();
                    //i--;
                }
            }

        </script>
</head>
<body>
<?php include(VIEWPATH . 'common/main_header.php'); ?>
<?php //var_dump($row);?>
<div align="center">
  <th><?= translate('ACTIVITY_ACTIVITYEDIT_ARENASTORE') ?></th>
</div>
<form action="" method="POST" id="rowForm">
  <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
      <?php for( $i = 0; $i < count($row); ++$i) {?>
    <table id ="p<?=$i ?>" width="100%" name="childP">
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ARENASTORE_SHELFID') ?>
          </div></td>
        <td >
            <input type="text" name="row[shelfid][]" id="shelfid<?=$i ?>" size="10" value="<?= $row[$i]['shelfid'] ?>">
        </td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ARENASTORE_RANK') ?>
          </div></td>
        <td >
            <input type="text" name="row[rank][]" id="rank<?=$i ?>" size="10" value="<?= $row[$i]['rank'] ?>">
        </td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ARENASTORE_COSTID') ?>
          </div></td>
        <td >
            <input type="text" name="row[cost_id][]" id="cost_id<?=$i ?>" value="<?= $row[$i]['cost_id'] ?>">
        </td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ARENASTORE_PRICE') ?>
          </div></td>
        <td >
            <input type="text" name="row[price][]" id="price<?=$i ?>" size="10" value="<?= $row[$i]['price'] ?>">
        </td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ARENASTORE_GIFTID') ?>
          </div></td>
        <td >
            <input type="text" size="39" placeholder="<?= translate('PLASE_INPUT_ITEM') ?>" 
                            	name="row[giftid][]" id="giftid<?=$i ?>" value = '<?=$row[$i]['giftid'] ?>' 
	                            	class="autocomplete" table="type_object" />
        </td>
      </tr>
      <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ARENASTORE_MAXCOUNT') ?>
          </div></td>
        <td >
            <input type="text" name="row[maxcount][]" id="maxcount<?=$i ?>" size="10" value="<?= $row[$i]['maxcount'] ?>">
        </td>
      </tr>
       <tr>
        <td><div align="center">
            <?= translate('ACTIVITY_ARENASTORE_SUBID') ?>
          </div></td>
        <td >
            <input type="text" name="row[subid][]" id="subid<?=$i ?>" size="10" value="<?= $row[$i]['subid'] ?>">
        </td>
      </tr>
    </table>
    <? } ?>
    <p id ="add">
    </p>
    
    <table width="100%">
      <tr>
        <td><div align="center">
            <input type="button" onClick="addp()" value="<?= translate('ADD_ONE') ?>" />
          </div></td>
        <td><div align="center">
            <input type="button" onClick="removep()" value="<?= translate('REMOVE_ONE') ?>" />
          </div></td>
      </tr>
      <tr>
        <td><div align="center">
            <input type="hidden" name="row[isEver]" value="<?= $row['isEver'] ?>">
            <input name="submit" type="submit" id="submit" value="<?= translate('SUBMIT') ?>"/>
          </div></td>
        <td><div align="center">
            <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
          </div></td>
      </tr>
    </table>
  </table>
</form>
<script type="text/javascript">
            SG.init("core.form", function() 
            {
                $.formValidator.initConfig({formid: "#rowForm", submitonce: true});
                for(var count =0; count < <?=count($row) ?>; ++count)
                {	
                	$("#shelfid"+count).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                	$("#rank"+count).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                	$("#price"+count).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                	//$("#giftid"+count).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                	$("#giftid"+count).formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                	//$("#giftbag_name"+count).formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                	$("#maxcount"+count).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                	$("#subid"+count).formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                }
            });
        </script>
</body>
</html>
